<template>
  <div id="app">
    <h2>学校名称:{{name}}</h2>
    <h2>学校地址:{{address}}</h2>
  </div>
</template>

<script>
import pubsub from 'pubsub-js'
export default {
  name: "School",
  data(){
    return{
      name:'武威职业学院',
      address:'武威市凉州区皇台路102号'
    }
  },
  methods:{
/*    getStudentName(name) {
      console.log("Shool接收到Student的姓名:",name)
    }*/
  },
  mounted() {
    // this.$bus.$on('hello',this.getStudentName)
    //订阅消息
    // this.pubId = pubsub.subscribe('hello',this.getStudentName)
    this.pubId = pubsub.subscribe('hello',(messageName,data)=>{
      console.log("Shool接收到Student的姓名:",data)
    })
  },
  beforeDestroy() {
    // this.$bus.$off('hello')
    pubsub.unsubscribe(this.pubId) //取消订阅
  }
}
</script>

<style scoped>
  #app{
    background-color: #ccc;
  }
  
</style>